package com.wwdx.controller.admin;

import com.wwdx.controller.base.BaseController;
import com.wwdx.model.ReVersionModel;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author liguoliang
 */
@Controller
@RequestMapping("/system/reversion")
public class ReVersionController extends BaseController{
    
    /**
     * 分页查询
     */
    @RequestMapping("/list")
    public ModelAndView index(ReVersionModel model,
                              @RequestParam(value = "page", defaultValue = "1") Integer page,
                              @RequestParam(value = "rows",defaultValue = "10") Integer rows) {

        ModelAndView mav = new ModelAndView();
        mav.addObject("listSize",  reVersionService.selectModelCount(model));
        mav.addObject("list",  reVersionService.selectModelList(model,page,rows));
        return mav;
    }

    /**
     * 新增
     */
    @RequestMapping("/create")
    public ModelAndView create() {
        return new ModelAndView();
    }
    
    /**
     * 保存新增
     */
    @RequestMapping("/save")
    public Object save(ReVersionModel model){
        reVersionService.save(model);
        return "redirect:/system/reversion/list";
    }

    /**
     * 修改
     */
    @RequestMapping("/edit")
    public ModelAndView edit(Long versionid) {
        ModelAndView mav = new ModelAndView();
        mav.addObject("model", reVersionService.getById(versionid));
        return mav;
    }
    /**
     * 保存修改
     */
    @RequestMapping("/update")
    public Object update(ReVersionModel model){
        reVersionService.update(model);
        return "redirect:/system/reversion/list";
    }
    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresRoles("super")
    public Object delete(Integer versionid) {
        reVersionService.delete(reVersionService.getById(versionid));
        return "redirect:/system/reversion/list";
    }
}